/* SwitchViewInspector.h
 * Written By:  Thomas Burkholder
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 */

// name space protected by wave

#import "WWTTSwitchViewIBInspector.h"

@implementation WWTTSwitchView (AttributesInspector)

- (const char *)getInspectorClassName
{
	NXEvent *ev = [NXApp currentEvent];

	if (ev->flags & NX_ALTERNATEMASK)
		return [super getInspectorClassName];
	else
		return "WWTTSwitchViewIBInspector";
}

@end

@implementation WWTTSwitchViewIBInspector

- init
{
	char buf[MAXPATHLEN + 1];
	id bundle;
	
	[super init];
	
	bundle = [NXBundle bundleForClass:[WWTTSwitchView class]];
	[bundle getPath:buf forResource:"WWTTSwitchViewIBInspector" ofType:"nib"];
	[NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
	
	return self;
}

- ok:sender
{
	if (![messageHowMatrix selectedRow])
		[messageTypeField setStringValue:""];
	[object setValueSelector:sel_getUid([messageTypeField stringValue])];
	[messageTypeField setEnabled:(BOOL)[messageHowMatrix selectedRow]];
	[object setInitialViewNumber:[initialField intValue]];
	return [super ok:sender];
}

- revert:sender
{
	[messageHowMatrix selectCellAt:([object valueSelector]!=(SEL)0) :0];
	[messageTypeField setEnabled:([object valueSelector]!=(SEL)0)];
	if ([object valueSelector]) {
		[messageTypeField setStringValue:sel_getName([object valueSelector])];
	} else {
		[messageTypeField setStringValue:""];
	}
	[initialField setIntValue:[object initialViewNumber]];
	return [super revert:sender];
}

- (BOOL)wantsButtons
{
	return NO;
}

@end
